<?php

namespace pmvc\annotation;

use Exception;

/**
 * An annotation for annotations to specify where
 * it  should be defined.  Valid values are:
 * 
 * <ul>
 * 	<li>class - {@code self::CLASSES}</li>
 *	<li>method - {@code self::METHODS}</li>
 *	<li>property - {@code self::PROPERTIES}</li>
 *	<li>function - {@code self::FUNCTIONS}</li>
 * </ul>
 * 
 * @\pmvc\annotation\Params(names=["locations"])
 * @\pmvc\annotation\Locations(locations=[self::CLASSES])
 */
class Locations
	extends AbstractAnnotation {

	const CLASSES		= "class";
	const METHODS		= "method";
	const PROPERTIES	= "property";
	const FUNCTIONS		= "function";
	const ANNOTATIONS	= "annotations";

	/**
	 * {@inheritDoc}
	 */
	protected function getAllowedParameterNames() {
		return Array("names");
	}

	/**
	 * {@inheritDoc}
	 */
	protected function validateAndTransformParameter($name, $value) {
		switch($name) {
			case "locations":
				if (!is_array($value)) {
					$value = Array($value);
				}
				$this->assertInArray($value, Array(
					self::CLASSES,
					self::METHODS,
					self::PROPERTIES,
					self::FUNCTIONS
				));
				return $value;
			default:
				return $value;
		}
	}

}

?>